package com.lxm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lxm.entity.Admin;
import com.lxm.dao.AdminMapper;
import com.lxm.service.IAdminService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lxm
 * @since 2021-11-18
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements IAdminService {

    @Override
    public Admin login(String username, String password) {
        //条件构造器：用于构建sql条件
        QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
        QueryWrapper<Admin> eq = queryWrapper.eq("username", username).eq("password", password);
        List<Admin> admins = baseMapper.selectList(eq);
        if(admins.size()==0){
            return null;
        }
        return admins.get(0);
    }
}
